import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:DELL
 * Time:21:54
 */
public class demo {
    List<List<Integer>> ret;
    List<Integer> path;
    public List<List<Integer>> subsets(int[] nums) {
        ret = new ArrayList<>();
        path = new ArrayList<>();
        dfs(nums,0);//从0位置开始
        return ret;
    }

    public void dfs(int[] nums,int pos){
        ret.add(new ArrayList<>(path));

        for(int i=pos;i<nums.length;i++){
            //添加
            path.add(nums[i]);
            dfs(nums,i+1);//遍历下一个数组
            path.remove(path.size()-1);//恢复现场
        }
    }
}
